 <template>
    <div class="field-control" :class="{'field-control-error': !validate}">
    <AutoCompleteControl :optionKey="rangeset.key || 'id'" @inputChange="inputChange" @selectChange="selectChange" :disabled="disabled" :renderTpl="renderTpl" :postData="fetchData" :path="fetchPath" :option-key="model.rangeset?model.rangeset.key:'id'" :option-code="model.rangeset?model.rangeset.name:'name'"  :initValue="value" @input="inputThis">
    </AutoCompleteControl>
    <div class="field-message" v-show="!validate">{{message}}</div>
    </div>
 </template>
 
 <script>
import base from "./ref";
import AutoCompleteControl from "@/components/autoComplete/index";
export default {
  extends: base,
  computed: {
    needClear() {
      return false;
    }
  },
  methods: {
    selectChange(v) {
      if (this.rangeset.mapping && v) {
        for (let i in this.rangeset.mapping) {
          if (i !== this.model.code) {
            this.$emit("extInput", {
              code: i,
              value: v[this.rangeset.mapping[i]]
            });
          }
        }
      }
    },
    inputThis(v) {
      this.$emit("input", v);
    },
    inputChange(v) {
      if (this.rangeset.mapping && this.needClear) {
        for (let i in this.rangeset.mapping) {
          if (i !== this.model.code) {
            this.$emit("extInput", {
              code: i,
              value: null
            });
          }
        }
      }
    }
  },
  components: {
    AutoCompleteControl
  }
};
</script>
 
 <style>

</style>
 
